/**
 * Created by lxh on 2018/1/3.
 */
import {allSeller,submitSeller} from "../services/adminPowerSettingApi";

export default {
    namespace: 'addSeller',
    state: {
        loading:true,
        data:{
            list:[],
            pagination:{}
        },
        sellerIdList:[],
    },

    effects: {
        *querySeller({payload,callback},{call,put}){
            yield put({
                type:'changeLoading',
                payload:true,
            });
            const response=yield call(allSeller,payload);
            yield put({
                type:'handleResponse',
                payload:response,
            });
            yield  put({
                type:'changeLoading',
                payload:false,
            });
            if(callback)callback(response);
        },
        *submitSeller({payload,callback},{call,put}){
            const response =yield call(submitSeller,payload);
            if(callback)callback(response);
        }
    },
    reducers: {
        changeLoading(state,{payload}){
            return({
                ...state,
                loading:payload,
            })
        },
        handleResponse(state,{payload}){
            return({
                ...state,
                data:payload.resultData.SellerList,
                sellerIdList:payload.resultData.sellerIdList,
            })
        },
    }
};





